package com.tianqu.tms.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.dto.TmsApiLogDto;

/**
 * @author Huang Wei
 *
 */
public class TmsApiLogDaoImp extends TmsDao implements TmsApiLogDao {

	protected TmsApiLogDaoImp() throws TmsDaoException {
		super();
	}
	
	@Override
	public void insertTmsApiLog(TmsApiLogDto dto) throws TmsDaoException {
		PreparedStatement ps = null;
		ResultSet rs = null;

		try {
			StringBuffer sql = new StringBuffer("INSERT INTO  ");
			sql.append(TmsTableNames.TMS_API_LOG);
			sql.append(" (  ");
			sql.append(" FUNCTYPE,  ");
			sql.append(" DATAINFO,  ");
			sql.append(" REASON,  ");
			sql.append(" UPDATEUSERID,  ");
			sql.append(" UPDATETIME  ");
			sql.append(" )  ");
			sql.append(" VALUES  ");
			sql.append(" (?,?,?,?,SYSDATE() ) ");
			ps = conn.prepareStatement(sql.toString());
			ps.setInt(1, dto.getFuncType());
			ps.setString(2, dto.getDataInfo());
			ps.setString(3, dto.getReason());
			ps.setInt(4, dto.getUpdateUserId());
			ps.executeUpdate();

		} catch (SQLException e) {
			throw new TmsDaoException(e.toString());
		} finally {
			super.close(rs, ps);
		}		
	}

}
